// 新建处的数据配置
const type = window.CONFIG.itemType; //1 产品 2 锦程  3 苏农
export function newOption(valueArray, formInfo, formFun) {
  const DIC = {
    VAILD: [{
        label: "真",
        value: "true"
      },
      {
        label: "假",
        value: "false"
      }
    ],
    Msg_lenve: [{
        label: "A",
        value: "A"
      },
      {
        label: "B",
        value: "B"
      },
      {
        label: "C",
        value: "C"
      }
    ],
    SEX: [{
        label: "男",
        value: 0
      },
      {
        label: "女",
        value: 1
      }
    ],
    bool: [{
      label: "",
      value: 0
    }]
  };
  const character = (rule, value, callback) => {
    var reg = /^[\s　]*$/
    if (!value) {
      return callback(new Error('请输入客户姓名'))
    } else if (reg.test(value)) {
      return callback(new Error('请输入正确的客户姓名'));
    } else {
      callback()
    }
  }
  const phone = (rule, value, callback) => {
    if (!value) {
      return callback(new Error('请输入客户号码'))
    } else if (!(/^[0-9]{1,20}$/.test(value))) {
      return callback(new Error('请输入正确的客户号码'));
    } else {
      return callback();
    }
  }
  return {
    size: valueArray.sizeValue,
    labelWidth: 90,
    emptyBtn: false,
    submitBtn: false,
    enter: false,
    disabled: valueArray.formTag == 0 ? true : false,
    column: [{
        label: '工单流程',
        filterable: true,
        prop: "workOrderTypeId",
        type: "select",
        dicData: valueArray.type,
        defaultIndex: '1',
        props: {
          label: "name",
          value: "id"
        },
        rules: [{
          required: true,
          message: "请选择类型",
          trigger: "change",
        }],
        span: 12,
        change: ({
          value,
          column
        }) => {
          formFun.changeRegion ? formFun.changeRegion(value) : ''
        },
      },
      {
        label: '问题分类',
        prop: "classifyData",
        type: "cascader",
        display: formFun.classifyShow ? true : false,
        checkStrictly: true,
        dicData: valueArray.classifyList,
        // defaultIndex: '1',
        props: {
          label: "name",
          value: "id",
          children: 'children',
        },
        rules: [{
          required: true,
          message: "请选择问题分类",
          trigger: "blur",
        }],
        span: 12,
        change: ({
          value,
          column
        }) => {
          formFun.changeProblem ? formFun.changeProblem(value) : ''
        },
      },
    ]
  };
}
// 工单列表搜索部分的数据配置
export function serOption(valueArray, formInfo, filterType) {
  return {
    labelWidth: 90,
    emptyBtn: false,
    submitBtn: false,
    enter: false,
    column: [
      // 产品的
      {
        label: "工单编号",
        prop: "workOrderId",
        type: "input",
        span: 8,
        display: true
      },
      {
        label: '状态',
        prop: "workOrderStatusId",
        type: "select",
        span: 8,
        display: true,
        dicData: valueArray.orderStatus,
        change: ({
          value,
          column
        }) => {
          formInfo[column.prop] = value;
        }
      },
      // 锦程基础的
      {
        label: "客户姓名",
        prop: "customer_name",
        type: "input",
        dataType: "string",
        display: type == '2' ? true : false,
        span: 8
      },
      {
        label: "身份证号",
        prop: "id_number",
        span: 8,
        dataType: "string",
        display: type == '2' ? true : false,

        type: 'input'
      }, {
        label: "申请号",
        prop: "application_number",
        span: 8,
        dataType: "string",
        display: type == '2' ? true : false,
        type: 'input'
      }, {
        label: "联系电话",
        prop: "phone_number",
        span: 8,
        dataType: "string",
        display: type == '2' ? true : false,
        type: 'input'
      },
      // 苏农定制字段
      {
        label: "客户姓名",
        prop: "customer_name",
        type: "input",
        display: type == '3' ? true : false,
        dataType: "string",
        span: 8
      },
      {
        label: '来电号码',
        prop: "phone_number",
        dataType: "string",
        display: type == '3' ? true : false,
        type: "input",
        span: 8
      },
      {
        label: '工单来源',
        prop: "source",
        display: type == '3' ? true : false,
        type: "select",
        span: 8,
        dicData: valueArray.sourceList,
        change: ({
          value,
          column
        }) => {
          formInfo[column.prop] = value;
        }
      },
      {
        label: "优先级",
        prop: "priority",
        display: type == '3' ? true : false,
        type: "select",
        span: 8,
        dicData: valueArray.priorityList,
        change: ({
          value,
          column
        }) => {
          formInfo[column.prop] = value;
        }
      },
      {
        label: "业务类型",
        prop: "business_type",
        display: type == '3' ? true : false,
        type: "select",
        span: 8,
        dicData: valueArray.businessTypeList,
        change: ({
          value,
          column
        }) => {
          formInfo[column.prop] = value;
        }
      },
      {
        label: "工单类型",
        prop: "order_type",
        display: type == '3' ? true : false,
        type: "select",
        span: 8,
        dicData: valueArray.orderTypeList,
        change: ({
          value,
          column
        }) => {
          formInfo[column.prop] = value;
        }
      },
      {
        label: "处理人涉及机构",
        prop: "handle_institution",
        display: type == '3' ? true : false,
        type: "cascader",
        span: 8,
        checkStrictly: true,
        dicData: valueArray.institutionList,
        change: ({
          value,
          column
        }) => {
          formInfo[column.prop] = value;
        }
      },
      // 产品的
      {
        label: "创建时间",
        prop: "createTime",
        valueFormat: "yyyy-MM-dd HH:mm:ss",
        type: "datetimerange",
        display: type !== '2' ? true : false,
        defaultTime: ['00:00:00', '23:59:59'],
        span: 10,
        change: ({
          value,
          column
        }) => {
          formInfo[column.prop] = value;
        }
      },
    ]
  };
}
// 锦程高级搜索条件
export function advanceFilterOption(valueArray, formInfo, filterType) {
  return {
    column: [{
        label: "业务类型",
        prop: "business_type",
        type: "select",
        span: 8,
        display: type == '2' ? true : false,
        dicData: valueArray.businessTypeList,
        change: ({
          value,
          column
        }) => {
          formInfo[column.prop] = value;
        }
      },
      {
        label: '工单来源',
        prop: "source",
        type: "select",
        span: 8,
        display: type == '2' ? true : false,
        dicData: valueArray.sourceList,
        change: ({
          value,
          column
        }) => {
          formInfo[column.prop] = value;
        }
      },
      {
        label: '创建人姓名',
        prop: "createUser",
        span: 8,
        labelWidth: 110,
        display: type == '2' ? true : false,
        dataType: "string",
        type: 'input'
      },
      {
        label: "优先级",
        prop: "priority",
        type: "select",
        span: 8,
        display: type == '2' ? true : false,
        dicData: valueArray.priorityList,
        change: ({
          value,
          column
        }) => {
          formInfo[column.prop] = value;
        }
      },
      {
        label: "当前处理人",
        prop: "current_handler_name",
        span: 16,
        formslot: true,
        display: type == '2' ? true : false,
      },
      {
        label: "创建时间",
        prop: "createTime",
        valueFormat: "yyyy-MM-dd HH:mm:ss",
        type: "datetimerange",
        display: type == '2' ? true : false,
        defaultTime: ['00:00:00', '23:59:59'],
        span: 10,
        change: ({
          value,
          column
        }) => {
          formInfo[column.prop] = value;
        }
      },
    ]
  }
}
